#!/usr/bin/env node 
//buffer 在创建时长度已经固定了
var buf1=new Buffer(256);
buf1[0]=0;
 console.log('buf1 length:'buf1.length);
 console.log('buf1 content:'buf1);
 for(var i=0;i<256;i++){
   buf1[i]=i;
 }
const buf2=buf1.slice(246,256);
console.log('buf2 length:'buf2.length,'buf2 content:'buf2);
buf2.fill(0);
console.log('buf2 content:'buf2);
const arr  =['Y','A','N','G'];
const buf3=new Buffer(arr)
console.log(buf3.length,buf3);
const str="forever yang";
const buf4=new Buffer(str,'utf8');
console.log(buf4.length,buf4);
console.log(buf4.toString());
buf4.copy(buf3,0,0,buf4.length);
console.log(buf3.toString('utf8'));

